home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / comms / other / zelador / sources / zeladormain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-06  |  3.2 KB  |  147 lines

  1. /* Main-Header File inserted by GenCodeC */
  2. /* Libraries */
  3. #include <libraries/mui.h>
  4. #include <libraries/gadtools.h> /* for BARLABEL in MenuItem */
  5.  
  6. /* Prototypes */
  7. #ifdef __GNUC__
  8. #include <proto/muimaster.h>
  9. #include <proto/exec.h>
  10. #include <proto/alib.h>
  11. #include <proto/dos.h>
  12. #else
  13. #include <clib/muimaster_protos.h>
  14. #include <clib/exec_protos.h>
  15. #include <clib/alib_protos.h>
  16. #include <clib/dos_protos.h>
  17. #include <pragmas/muimaster_pragmas.h>
  18. #endif /* __GNUC__ */
  19.  
  20. /*  Ansi  */
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23.  
  24. /* Increase stack size */
  25. LONG __stack=8192;
  26. /* GenCodeC header end */
  27.  
  28. /* Include generated by GenCodeC */
  29. #include "ZeladorGUI.h"
  30.  
  31. /* includes inseridos por mim..    */
  32. #include "Zelador_Nucleo.c"
  33. #include <exec/exec.h>
  34. #include <devices/timer.h>
  35.  
  36. /* variáveis inseridas por mim..    */
  37. struct timerequest * MeuTimerVBLANK;    /* usado pelo timer vblank    */
  38. struct MsgPort * MeuTimerVBLANKmp;
  39. FILE * ArqLogEFR;            /* arquivos de LOG    */
  40. FILE * ArqLogRR;
  41. FILE * ArqLogGeral;
  42.  
  43. /* Declarations for libraries (inserted by GenCodeC) */
  44. struct Library * IntuitionBase;
  45. struct Library * MUIMasterBase;
  46.  
  47. /* Init() function */
  48. void init( void )
  49. {
  50.     if (!(IntuitionBase = OpenLibrary("intuition.library",37)))
  51.     {
  52.         printf("Can't Open Intuition Library\n");
  53.         exit(20);
  54.     }
  55.     if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
  56.     {
  57.         printf("Can't Open MUIMaster Library\n");
  58.         CloseLibrary(IntuitionBase);
  59.         exit(20);
  60.     }
  61.  
  62.     MeuTimerVBLANKmp = CreateMsgPort ();
  63.     if (!(MeuTimerVBLANK = CreateIORequest (MeuTimerVBLANKmp, sizeof(timerequest))))
  64.     {
  65.         printf("Can't Create IORequest\n");
  66.         DeleteMsgPort (MeuTimerVBLANKmp);
  67.         CloseLibrary(MUIMasterBase);
  68.         CloseLibrary(IntuitionBase);
  69.         exit(20);
  70.     }
  71.  
  72.     if (OpenDevice ("timer.device", UNIT_VBLANK, &MeuTimerVBLANK->tr_node, 0))
  73.     {
  74.         printf("Can't Open Timer Device\n");
  75.         DeleteIORequest (MeuTimerVBLANK);
  76.         DeleteMsgPort (MeuTimerVBLANKmp);
  77.         CloseLibrary(MUIMasterBase);
  78.         CloseLibrary(IntuitionBase);
  79.         exit(20);    
  80.     }
  81.  
  82.     if (InicializaREXX())
  83.     {
  84.         printf("Can't Open ARexx Communication\n");
  85.         CloseDevice (&MeuTimerVBLANK->tr_node);
  86.         DeleteIORequest (MeuTimerVBLANK);
  87.         DeleteMsgPort (MeuTimerVBLANKmp);
  88.         CloseLibrary(MUIMasterBase);
  89.         CloseLibrary(IntuitionBase);
  90.         exit(20);        
  91.     }
  92.  
  93.     ArqLogEFR=fopen("logs/EFR.log","a");
  94.     ArqLogRR=fopen("logs/RR.log", "a");
  95.     ArqLogGeral=fopen("logs/general.log", "a");    
  96. }
  97. /* GenCodeC init() end */
  98.  
  99. /* End() function */
  100. void end( void )
  101. {
  102.     if (ArqLogEFR)
  103.         fclose(ArqLogEFR);
  104.  
  105.     if (ArqLogRR)
  106.         fclose(ArqLogRR);
  107.  
  108.     if (ArqLogGeral)
  109.         fclose(ArqLogGeral);
  110.  
  111.     FechaREXX ();
  112.     AbortIO (&MeuTimerVBLANK->tr_node);
  113.     WaitIO (&MeuTimerVBLANK->tr_node);
  114.     CloseDevice (&MeuTimerVBLANK->tr_node);
  115.     DeleteIORequest (MeuTimerVBLANK);
  116.     DeleteMsgPort (MeuTimerVBLANKmp);
  117.     CloseLibrary(MUIMasterBase);
  118.     CloseLibrary(IntuitionBase);
  119.     
  120.     exit(0);
  121. }
  122. /* GenCodeC end() end */
  123.  
  124. /* variáveis GLOBAIS inseridas por mim..    */
  125. struct ObjApp * MeuApp = NULL;    /* Object */
  126.  
  127. /* Main Function inserted by GenCodeC */
  128. int main(int argc,char **argv)
  129. {
  130.     BOOL    running = TRUE;
  131.  
  132.     /* Program initialisation : generated by GenCodeC */
  133.     init();
  134.  
  135.     /* Create Object : generated by GenCodeC */
  136.     if (!(MeuApp = CreateApp()))
  137.     {
  138.         printf("Can't Create App\n");
  139.         end();
  140.     }
  141.  
  142.     ProcessamentoCentral ();
  143.  
  144.     DisposeApp(MeuApp);
  145.     end();
  146. }
  147.